﻿using System.Windows;
using FullApp1.Modules.ModuleName;
using FullApp1.Modules.ModuleName.Models;
using FullApp1.Modules.ModuleName.Views;
using FullApp1.Services;
using FullApp1.Services.Interfaces;
using FullApp1.ViewModels;
using FullApp1.Views;
using Prism.Events;
using Prism.Ioc;
using Prism.Modularity;
using Prism.Mvvm;

namespace FullApp1
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App
    {
        protected override Window CreateShell()
        {
            return Container.Resolve<MainWindow>();
        }

        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            // 核心服务
            containerRegistry.RegisterSingleton<ILicenseService, LicenseService>();
            containerRegistry.RegisterSingleton<IEventAggregator, EventAggregator>();
            containerRegistry.RegisterSingleton<MainWindow>();


            // 注册服务
            containerRegistry.RegisterSingleton<IExportService, ExportService>();

            // 注册视图导航
            containerRegistry.RegisterForNavigation<ExistingPageView>("ExistingPage");
            containerRegistry.RegisterForNavigation<LicenseDetailView>("LicenseDetail");


            // 注册执照类型
            containerRegistry.RegisterSingleton<LicenseInfo>();
            // 对话框服务
            //containerRegistry.RegisterDialog<ExportProgressDialog>();            
            containerRegistry.RegisterDialog<OperatorDetailDialog>();

            // 配置日志
            //containerRegistry.RegisterInstance<ILogger>(new FileLogger("app.log"));
        }
                

        protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
        {
            moduleCatalog.AddModule<ModuleNameModule>();
        }
        
        protected override void ConfigureViewModelLocator()
        {
            base.ConfigureViewModelLocator();

            //ViewModelLocationProvider.Register<MainWindow, MainWindowViewModel>();
            ViewModelLocationProvider.SetDefaultViewModelFactory((type) => Container.Resolve(type));


        }
    }
}
